package com.cc.demo.service;

import com.cc.demo.entity.Order;
import com.cc.demo.repository.OrderRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class OrderService {

    private final OrderRepository orderRepository;


    @Transactional
    public void createOrder(Order order) {
        orderRepository.save(order);
    }

    @Transactional(readOnly = true)
    public boolean checkOrderStatus(Integer id) {
        return !orderRepository.findById(id).isEmpty();
    }
}
